/*********************************************************************************
 * 
 * Author: wujunjie
 * Create Date: 2014-05-10
 * Description:
 *          
 * Revision History:
 *      Date          Author               Description
 * 
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess;
using Xinkui.Entity.AutoGenerator;
using Xinkui.Common;
namespace Xinkui.DataAccess.AutoGenerator {
    public partial class BuyleadInfoMaintainDataAccess {
        public List<BuyleadInfoMaintain_Entity> BuyleadInfoMaintain_ListByPaging(int pageSize, int pageIndex, out int total) {
            total = 0;
            try {
                int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("BuyleadInfoMaintain_ListByPaging");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
                cmd.SetParameterValue("@RecordCount", tempRecord);
                List<BuyleadInfoMaintain_Entity> pageList = cmd.ExecuteEntityList<BuyleadInfoMaintain_Entity>();
                total = Convert.ToInt32(cmd.GetParameterValue("@RecordCount"));
                return pageList;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<BuyleadInfoMaintain_Entity>(0);

        }

        public BuyleadInfoMaintain_Entity BuyleadInfoMaintain_View(System.Int32 BuyleadID) {
            BuyleadInfoMaintain_Entity c = default(BuyleadInfoMaintain_Entity);
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("BuyleadInfoMaintain_View");
                cmd.SetParameterValue("@BuyleadID", BuyleadID);
                c = cmd.ExecuteEntity<BuyleadInfoMaintain_Entity>();
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return c;
        }

        public BuyleadInfoMaintain_Entity BuyleadInfoMaintain_Add(BuyleadInfoMaintain_Entity entity) {
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("BuyleadInfoMaintain_Add");
                cmd.SetParameterValue("@BuyleadID", entity.BuyleadID);
                cmd.SetParameterValue("@Subject", entity.Subject);
                cmd.SetParameterValue("@CategoryID", entity.CategoryID);
                cmd.SetParameterValue("@MainKeyword", entity.MainKeyword);
                cmd.SetParameterValue("@Keywords", entity.Keywords);
                cmd.SetParameterValue("@PurchaseType", entity.PurchaseType);
                cmd.SetParameterValue("@Country", entity.Country);
                cmd.SetParameterValue("@Details", entity.Details);
                cmd.SetParameterValue("@OEMNO", entity.OEMNO);
                cmd.SetParameterValue("@Packing", entity.Packing);
                cmd.SetParameterValue("@Quantity", entity.Quantity);
                cmd.SetParameterValue("@ValidDate", entity.ValidDate);
                cmd.SetParameterValue("@ValidTime", entity.ValidTime);
                cmd.SetParameterValue("@PriceRange", entity.PriceRange);
                cmd.SetParameterValue("@CertificationRequirements", entity.CertificationRequirements);
                cmd.SetParameterValue("@OrderQuantity", entity.OrderQuantity);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@UserID", entity.UserID);
                cmd.SetParameterValue("@CreateDate", entity.CreateDate);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.SetParameterValue("@ReSubmitDate", entity.ReSubmitDate);
                cmd.SetParameterValue("@AuditStatus", entity.AuditStatus);
                cmd.SetParameterValue("@AuditDate", entity.AuditDate);
                cmd.SetParameterValue("@IsDeleted", entity.IsDeleted);
                cmd.SetParameterValue("@AdminModifyDate", entity.AdminModifyDate);
                cmd.SetParameterValue("@AdminID", entity.AdminID);
                cmd.SetParameterValue("@PicImgs", entity.PicImgs);
                cmd.ExecuteNonQuery();
                entity.BuyleadID = (int)cmd.GetParameterValue("@BuyleadID");
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return entity;
        }

        public bool BuyleadInfoMaintain_Update(BuyleadInfoMaintain_Entity entity) {
            bool succ = false;
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("BuyleadInfoMaintain_Update");
                cmd.SetParameterValue("@BuyleadID", entity.BuyleadID);
                cmd.SetParameterValue("@Subject", entity.Subject);
                cmd.SetParameterValue("@CategoryID", entity.CategoryID);
                cmd.SetParameterValue("@Country", entity.Country);
                cmd.SetParameterValue("@MainKeyword", entity.MainKeyword);
                cmd.SetParameterValue("@Keywords", entity.Keywords);
                cmd.SetParameterValue("@PurchaseType", entity.PurchaseType);
                cmd.SetParameterValue("@Details", entity.Details);
                cmd.SetParameterValue("@OEMNO", entity.OEMNO);
                cmd.SetParameterValue("@Packing", entity.Packing);
                cmd.SetParameterValue("@Quantity", entity.Quantity);
                cmd.SetParameterValue("@ValidDate", entity.ValidDate);
                cmd.SetParameterValue("@ValidTime", entity.ValidTime);
                cmd.SetParameterValue("@PriceRange", entity.PriceRange);
                cmd.SetParameterValue("@CertificationRequirements", entity.CertificationRequirements);
                cmd.SetParameterValue("@OrderQuantity", entity.OrderQuantity);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@UserID", entity.UserID);
                cmd.SetParameterValue("@CreateDate", entity.CreateDate);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.SetParameterValue("@ReSubmitDate", entity.ReSubmitDate);
                cmd.SetParameterValue("@AuditStatus", entity.AuditStatus);
                cmd.SetParameterValue("@AuditDate", entity.AuditDate);
                cmd.SetParameterValue("@IsDeleted", entity.IsDeleted);
                cmd.SetParameterValue("@AdminModifyDate", entity.AdminModifyDate);
                cmd.SetParameterValue("@AdminID", entity.AdminID);
                cmd.SetParameterValue("@PicImgs", entity.PicImgs);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

        public bool BuyleadInfoMaintain_Delete(System.Int32 BuyleadID) {
            bool succ = false;
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("BuyleadInfoMaintain_Delete");
                cmd.SetParameterValue("@BuyleadID", BuyleadID);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

    }
}
